/*
 * c7_exercise10.cpp
 *
 *  Created on: Sep 2, 2013
 *      Author: cyper.yin
 */

#include <iostream>
using namespace std;

double add(double, double);
double subtract(double, double);
double multiply(double, double);
double calculate(double, double, double (*fp[])(double, double));

const int SIZE = 3;

int main(int argc, char **argv) {
	double (*fp[])(double, double) = {add, subtract, multiply};

	cout << "Enter a b:";
	double a, b;
	while (cin >> a >> b) {
		double q = calculate(a, b, fp);
		cout << "fancy result is :"  << q << endl;
		cout << "Enter a b:";
	}

	return 0;
}
double add(double a, double b) {
	return a + b;
}
double subtract(double a, double b) {
	return a - b;
}
double multiply(double a, double b) {
	return a * b;
}

double calculate(double a, double b, double (*fp[])(double, double)) {
	return fp[2](fp[0](a, b), fp[1](a, b));
}

